/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"40022C62-4404-4793-9BC7-6B9E2C7C103C"}
 */
function agregar(event) {
	ficha_clinica_to_ficha_detalle.newRecord()
	forms.ficha_detalle_dtl_carga.controller.loadRecords(ficha_clinica_to_ficha_detalle)
	application.showFormInDialog(forms.ficha_detalle_dtl_carga,-1,-1,-1,-1,'Nuevo Detalle de Ficha',false,false,'FIDTL',true)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"25C72385-BB6A-4903-889C-49229F3DAA8E"}
 */
function eliminar(event) {
	ficha_clinica_to_ficha_detalle.deleteRecord()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"35A02D92-D8DC-44CE-9A23-C1524BC71B1E"}
 */
function confirmar(event) {
	if (!elements.btn_agg.enabled)
	{
		if (texto == '<Ingrese un texto...>' || texto == null || texto == ' ')
		{
			globals.gDialog('Error','Debe agregar un texto','OK','CerrarForm')
			return 0
		}
		databaseManager.saveData(foundset.getRecord(foundset.getSelectedIndex()))
		elements.btn_agg.enabled = true
		elements.btn_del.enabled = true
		globals.gDialog('Exito','Ya puede cargar los detalles','OK','CerrarForm')
	}
	else
	{
		globals.gDialog('Exito','La ficha fue dada de alta exitosamente','OK','CerrarForm')
	}
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"B5287866-FC22-490C-8053-5C4103778788"}
 */
function cancelar(event) {
	ficha_clinica_to_ficha_detalle.deleteAllRecords()
	controller.deleteRecord()
	globals.gDialog('Exito','La ficha fue dada de BAJA','OK','CerrarForm')
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"49DE28BB-2512-4485-8530-9EB4A3614362"}
 */
function onShow(firstShow, event) {
	//globals.gUsuario = 1 //TODO
	controller.newRecord()
	usuario_id = globals.gUsuario
	elements.btn_agg.enabled = false
	elements.btn_del.enabled = false
}

/**
 * Handle focus element gaining focus.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"C782E99B-6AA1-4734-9C3E-A18208169D83"}
 */
function onFocusGained(event) {
	if (texto == '<Ingrese un texto...>')
		texto = ' '
	return true
}
